import hanlp
from py2neo import Graph, Node, Relationship
from py2neo.matching import NodeMatcher, RelationshipMatcher

HanLP = hanlp.load(hanlp.pretrained.mtl.CLOSE_TOK_POS_NER_SRL_DEP_SDP_CON_ELECTRA_SMALL_ZH)  # 加载中文语料库
# doc = HanLP(['nm的评分是多少。', 'nm得了多少分。'])

HanLP('霸王别姬的电影评分是多少', tasks='tok/fine').pretty_print()
b = HanLP('霸王别姬的电影评分是多少')
list_data = b['tok/coarse']
list_train = ['评分', '分数', '得分']
graph = Graph("bolt://localhost:7687", auth=("neo4j", "123456"))
matcher = NodeMatcher(graph)
movies = matcher.match("Movie")
genres = matcher.match("Genre")
directors = matcher.match("Director")
actors = matcher.match("Actor")

for a in list_data:
    if matcher.match("Movie", name=a).first():
        movie = matcher.match("Movie", name=a).first()
        print(movie)
    else:
        continue
    if any(word if word in list_train else False for word in list_data):
        print(f"{a}的评分是{movie['star']}")
        break

for i in range(10):
    for j in range(10):
        j = i + j / 10
        print(j)

